home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8" ?>
- <!DOCTYPE stack PUBLIC "-//Apple, Inc.//DTD stack V 2.0//EN" "" >
- <stack>
- <name>in</name>
- <id>-1</id>
- <cardCount>2</cardCount>
- <cardID>2935</cardID>
- <listID>4177</listID>
- <cantModify><false /></cantModify>
- <cantDelete><false /></cantDelete>
- <cantAbort><false /></cantAbort>
- <cardSize>
- <width>448</width>
- <height>824</height>
- </cardSize>
- <script>
- -- Browser 2.1
- -- Copyright © 1990-91 Apple Computer, Inc.
-
-
-
- -- Initialize browser
- ————————————————————————————————————————————————————————————————————————
- on openStack
-
- global BrowserInited, BrowserPath, DocumentList, Pegasus
-
- set cursor to watch
-
- put "Reference Library" into Pegasus
-
- if BrowserInited = true then exit openStack
-
- -- Check the HC version, size
-
- if the long version < 02018000 then
- answer "This stack requires the use of HyperCard" ¬
- && "version 2.0v2 or later."
- set lockMessages to true
- go home
- exit to HyperCard
- end if
-
- if the heapSpace < 750000 then
- answer "HyperCard needs more memory. Please increase the current" ¬
- && "memory size in HyperCard's info window to at least 1,600K."
- set lockMessages to true
- go home
- exit to HyperCard
- end if
-
- -- Initialize the browser
-
- put value of word 2 to 99999 of long name ¬
- of this stack into BrowserPath
- initBrowser
- if DocumentList is empty then openDocument
-
- end openStack
-
-
-
- -- Shut down the browser
- ————————————————————————————————————————————————————————————————————————
- on closeStack
-
- global DocumentList, BrowserPath
-
- if BrowserPath ≠ value of word 2 to 99999 of long name of this stack ¬
- then exit closeStack
-
- if DocumentList is empty ¬
- and "search" is not in the stacks ¬
- and "interfaces browser" is not in the stacks ¬
- and "help" is not in the stacks then shutDownBrowser
-
- end closeStack
-
-
-
- -- If the user quits HyperCard and the browser's still inited, shut down
- ————————————————————————————————————————————————————————————————————————
- on quit
- global BrowserInited
- if BrowserInited = true then shutDownBrowser
- end quit
-
-
-
- -- Set a flag when the user quits HyperCard
- ————————————————————————————————————————————————————————————————————————
- on doMenu theItem
-
- global HyperCardIsQuitting
-
- put (theItem is "quit hypercard") into HyperCardIsQuitting
- pass doMenu
-
- end doMenu
-
-
-
- -- Initialize the browser
- ————————————————————————————————————————————————————————————————————————
- on initBrowser
-
- global BrowserInited, BrowserPath, BrowserFolder
-
- getPreferences
- loadDocumentList
- loadBookmarks
- loadNotesDirectory
- findSearch
- findInterfaces
- installMenus
- start using stack BrowserPath
- put true into BrowserInited
-
- end initBrowser
-
-
-
- -- Init globals from preferences
- ————————————————————————————————————————————————————————————————————————
- on getPreferences
-
- global PreferencesFolder, BrowserPath, BrowserFolder, ¬
- InitialWindowLoc, InterfacesType, Pegasus, ¬
- InterfacesWindowRect, NoteWindowRect, CurrentDocNum
-
- -- Find or create the preferences folder
-
- if AUXIsRunning() = True then put item 2 of sysPrefs(empty) ¬
- & Pegasus && "Stuff/" into PreferencesFolder
-
- else put item 2 of sysPrefs(empty) & Pegasus && "Stuff:" ¬
- into PreferencesFolder
-
- if fileExists (PreferencesFolder) = false then
- get createFolder(PreferencesFolder)
- if it ≠ 0 then exit getPreferences
- end if
-
- -- Get its contents, set globals with it
-
- put PreferencesFolder & "Preferences" into preferencesFile
- open file preferencesFile
- read from file preferencesFile until "" -- EOF
- put it into preferences
- close file preferencesFile
-
- if BrowserPath is empty then
- put line 1 of preferences into BrowserPath
- else put true into setDefaults
- put pathPrefix(BrowserPath) into BrowserFolder
-
- put line 2 of preferences into NoteWindowRect
- if NoteWindowRect is empty then
- put "20,52,360,252" into NoteWindowRect
- put true into setDefaults
- end if
-
- if setDefaults = true then setPreferences
- put zero into CurrentDocNum
-
- end getPreferences
-
-
-
- -- Write the preferences to the preferences file
- ———————————————————————————————————————————————————————————————————————
- on setPreferences
-
- global PreferencesFolder, BrowserPath, InterfacesType, ¬
- InterfacesWindowRect, NoteWindowRect
-
- put PreferencesFolder & "Preferences" into preferencesFile
- open file preferencesFile
- get BrowserPath & return & NoteWindowRect
- write it to file preferencesFile
- close file preferencesFile
-
- end setPreferences
-
-
-
- -- Get the notes directory
- ————————————————————————————————————————————————————————————————————————
- on loadNotesDirectory
-
- global PreferencesFolder, NotesDirectory
-
- put folderContents(PreferencesFolder,"Files") ¬
- & return into NotesDirectory
-
- end loadNotesDirectory
-
-
-
- -- Go to the browser
- ————————————————————————————————————————————————————————————————————————
- on goBrowser
-
- global BrowserPath, DocBrowserType
-
- set cursor to watch
- put (BrowserPath is not in the stacks) into needUpdate
- go cd DocBrowserType of stack BrowserPath in new window
-
- if the result is not empty then
- go stack BrowserPath in new window
- else if needUpdate then
- updateBrowser true
- disable menuItem "open browser" of menu "browser"
- end if
-
- end goBrowser
-
-
-
- -- Open a document stack that's not already open
- ————————————————————————————————————————————————————————————————————————
- on openDocument docNum
-
- global DocumentList
-
- if docNum is empty then
- put fileName("STAK","Please select a document stack.") into docPath
- else put item 1 of line docNum of DocumentList into docPath
- set cursor to watch
-
- if docPath is empty then exit openDocument
- if validDocPath(docPath) = false then exit openDocument
- if docPath is in the stacks then
- show window truncFile(docPath)
- exit openDocument
- end if
-
- go stack docPath in a new window
-
- end openDocument
-
-
-
- -- Initialize a document
- ————————————————————————————————————————————————————————————————————————
- on initDocument docPath
-
- global DocumentList, DocumentFolder, DocRefNum, DocBrowserType, ¬
- DocumentName, DocumentPath, CurrentDocNum
-
- -- Store information about the document being inited
-
- put docPath into DocumentPath
- put pathPrefix(DocumentPath) into DocumentFolder
- put truncFile(DocumentPath) into DocumentName
- put openBrowserFiles(DocumentFolder) into DocRefNum
- get IndeXFCN(iGet,DocRefNum,80,"%S","Document.Info","T")
- put line 4 of it into DocBrowserType
-
- -- Is this an existing (in the list) or a new document?
-
- put (DocumentList is empty) into newDoc
- if not newDoc then
- findInXCMD DocumentList,DocumentName,1
- put item 1 of the result into docNum
- put (docNum = 0) into newDoc
- end if
-
- -- If the doc is not in the doc list, add it to the list and menu;
- -- otherwise, just update the list and menu
-
- if newDoc then
- if DocumentList is empty then -- the list is empty
- put "-" after menu "documents"
- put 1 into docNum
- else -- the list is not empty
- put (number of lines in DocumentList) + 1 into docNum
- end if
- end if
-
- -- Add it to the doc list and the doc menu
-
- put DocumentPath & "," & DocBrowserType & "," & DocRefNum into docEntry
- put "openDocument" && docNum into docMsg
-
- if newDoc is true then
- put docEntry & return after DocumentList
- put DocumentName after menu "documents" with menuMsg docMsg
- else
- put docEntry into line docNum of DocumentList
- put DocumentName into menuItem docNum + 2 of menu "documents" ¬
- with menuMsg docMsg
- end if
-
- put docNum into CurrentDocNum
- updateDocMenuMarks
-
- end initDocument
-
-
-
- -- The document's closeStack calls this routine
- ————————————————————————————————————————————————————————————————————————
- on closeDocument
-
- global BrowserPath, DocumentList, DocBrowserType, HyperCardIsQuitting, ¬
- DocRefNum
-
- -- Forget it was ever open
-
- set cursor to watch
- updateDocMenuMarks false
- get indeXFCN(iClose,DocRefNum)
- put empty into DocRefNum
- put empty into DocBrowserType
-
- -- Let the user keep the doc on the menu
-
- if HyperCardIsQuitting is true then exit closeDocument
-
- if the shiftKey is up then
- answer "Keep this document in the menu?" with ¬
- "Remove it" or "Keep it"
- if it is "Keep it" then exit closeDocument
- end if
-
- -- Remove it from the menu
-
- set cursor to watch
- put value of word 2 to 99999 of long name of this stack into docPath
- put truncFile(docPath) into docName
-
- if there is a menu "documents" then
- if there is a menuItem docName of menu "documents" then ¬
- delete menuItem docName of menu "documents"
- end if
-
- -- Delete the document's entry in the document list
-
- if DocumentList is not empty then
- findInXCMD DocumentList, docPath, 1
- put item 1 of the result into docNum
- delete line docNum of DocumentList
- end if
-
- -- Fix the menu messages
-
- if DocumentList is not empty then
-
- repeat with d = 1 to number of lines in DocumentList
- set menuMsg of menuItem d + 2 of menu "documents" to ¬
- "openDocument" && d
- end repeat
-
- -- If no docs left open, delete the divider
-
- else
- if there is a menu "documents" then
- if number of menuItems in menu "documents" = 2 then ¬
- delete menuItem 2 of menu "documents" -- the dividing line
- end if
- end if
-
- end closeDocument
-
-
-
- -- When the last stack is closed, shut down the browser
- ————————————————————————————————————————————————————————————————————————
- on shutDownBrowser
-
- global BrowserInited, BrowserPath, DocRefNum, DocumentList, SearchPath
-
- set cursor to watch
- lock screen
-
- put 0 into CurrentDocNum
- if DocRefNum is not empty then get IndeXFCN(iClose,DocRefNum)
-
- saveDocumentList
- saveBookmarks
- setPreferences
-
- if there is a menu "browser" then delete menu "browser"
- if there is a menu "documents" then delete menu "documents"
-
- stop using stack BrowserPath
- stop using stack SearchPath
- put empty into DocumentList
- put empty into BrowserInited
-
- end shutDownBrowser
-
-
-
- -- Install the menus
- ————————————————————————————————————————————————————————————————————————
- on installMenus
-
- global DocumentList, Bookmarks, SearchInited, InterfacesInited, ¬
- BrowserPath
-
- if "Help" is in menu "Go" then delete menuItem "Help" of menu "Go"
- if there is a menu "Font" then delete menu "Font"
- if there is a menu "Style" then delete menu "Style"
-
- put "Open Browser,-,Print Selected Text,Print Section," ¬
- & "Print Chapter,-,Open Note,Help" into theItems
- put "goBrowser,-,printText theselection,printText section," ¬
- & "printText chapter,-,openNotes,goHelp" into theMsgs
-
- if SearchInited = true then
- put ",-,Search...,Prev Match,Next Match" after theItems
- put ",-,goSearch,goHit prev,goHit next" after theMsgs
- end if
-
- if InterfacesInited = true then
- put ",-,Interfaces Browser...,Interfaces Lookup..." after theItems
- put ",-,goInterfaces browser,goInterfaces lookup" after theMsgs
- end if
-
- if there is not a menu "browser" then create menu "Browser"
- put theItems into menu "browser" with menuMsgs theMsgs
-
- set cmdchar of menuItem "open browser" of menu "browser" to "U"
- set cmdchar of menuItem "open note" of menu "browser" to "Y"
-
- if InterfacesInited = true then
- set cmdchar of menuItem "interfaces browser..." of menu "browser" to "I"
- set cmdchar of menuItem "interfaces lookup..." of menu "browser" to "K"
- end if
-
- if SearchInited = true then
- set cmdchar of menuItem "search..." of menu "browser" to "\"
- set cmdchar of menuItem "prev match" of menu "browser" to "["
- set cmdchar of menuItem "next match" of menu "browser" to "]"
- disable menuItem "prev match" of menu "browser"
- disable menuItem "next match" of menu "browser"
- end if
-
- if there is not a menu "documents" then create menu "Documents"
-
- put "Open a Document..." into menu "documents" ¬
- with menuMsg "openDocument"
-
- -- If there is a current document list, init the menu from it
-
- if DocumentList ≠ empty then
- put "-" after menu "documents" -- divider
- repeat with d = 1 to number of lines in DocumentList
- get item 1 of line d of DocumentList
- put "openDocument" && d into theMsg
- put truncFile(it) after menu "documents" with menuMsg theMsg
- end repeat
- end if
-
- -- Install the bookmarks menu
-
- if there is not a menu "bookmarks" then create menu "Bookmarks"
-
- put "Set a Bookmark...,Clear a Bookmark...," ¬
- & "Clear All Bookmarks..." into theItems
- put "setBookmark,clearOneBookmark,clearAllBookmarks" into theMsgs
-
- if Bookmarks ≠ empty then
- put ",-" after theItems
- put "," after theMsgs
- repeat with b = 1 to number of lines in Bookmarks
- get item 4 of line b of Bookmarks
- put "," & it after theItems
- put ",goBookmark" && quote & it & quote after theMsgs
- end repeat
- end if
-
- put theItems into menu "bookmarks" with menuMsgs theMsgs
- set cmdchar of menuItem "set a bookmark..." of menu "bookmarks" to ";"
-
- enableDocMenus false
-
- end installMenus
-
-
-
- -- Replace our menus if another stack killed 'em
- ———————————————————————————————————————————————————————————————————————
- on resumeStack
- if there is not a menu "browser" then installMenus
- end resumeStack
-
-
-
- -- Make the specified document the current document
- ———————————————————————————————————————————————————————————————————————
- on resumeDocument docPath
-
- global DocumentList, DocumentFolder, DocBrowserType, DocRefNum, ¬
- CurrentDocNum, BrowserPath, DocumentName, DocumentPath, SearchInited
-
- set cursor to watch
- if there is not a menu "browser" then installMenus
-
- if DocumentList is empty then exit resumeDocument -- shouldn't happen
- if lockScreen is false then lock screen
-
- -- Find the resuming document's entry in the document list
-
- findInXCMD DocumentList, docPath, 1
- put item 1 of the result into CurrentDocNum
- get line CurrentDocNum of DocumentList
-
- -- Set up the current document globals
-
- put item 1 of it into DocumentPath
- put pathPrefix(DocumentPath) into DocumentFolder
- put truncFile(DocumentPath) into DocumentName
- put item 2 of it into DocBrowserType
- put item 3 of it into DocRefNum
-
- updateDocMenuMarks
- if number of this cd > 1 then enableDocMenus true
- if SearchInited then enableSearchMenus
-
- end resumeDocument
-
-
-
- -- A document stack is going into the background
- ———————————————————————————————————————————————————————————————————————
- on suspendDocument docName
- enableDocMenus false
- end suspendDocument
-
-
-
- -- Enable/disable those menu items used only by document stacks
- ————————————————————————————————————————————————————————————————————————
- on enableDocMenus isEnabled
-
- global HitCardCount, Bookmarks, SearchInited
-
- set enabled of menuItem "print selected text" of menu "browser" to isEnabled
- set enabled of menuItem "print section" of menu "browser" to isEnabled
- set enabled of menuItem "print chapter" of menu "browser" to isEnabled
- set enabled of menuItem "open note" of menu "browser" to isEnabled
- set enabled of menuItem "set a bookmark..." of menu "bookmarks" to isEnabled
-
- if Bookmarks is empty then
- disable menuItem "clear a bookmark..." of menu "bookmarks"
- disable menuItem "clear all bookmarks..." of menu "bookmarks"
- end if
-
- end enableDocMenus
-
-
-
- -- Go to the appropriate card in the help stack
- ————————————————————————————————————————————————————————————————————————
- on goHelp where
-
- global BrowserFolder
-
- set cursor to busy
- lock screen
-
- -- The "helpCard" handler in the current card, background or stack
- -- tells us where to go
-
- if where is empty then
- send helpCard to this cd
- get the result
- end if
-
- go cd (it) of stack BrowserFolder & "Support files:Help" ¬
- in new window
-
- if the result is not empty then ¬
- go stack BrowserFolder & "Support files:Help" in new window
-
-
- end goHelp
-
-
-
- -- This handler tells the goHelp handler which help stack card to go to
- ————————————————————————————————————————————————————————————————————————
- on helpCard
- return 1
- end helpCard
-
-
-
- -- Open the search stack
- ————————————————————————————————————————————————————————————————————————
- on goSearch
- global SearchInited, SearchPath
- if SearchInited is true then go stack SearchPath in a new window
- end goSearch
-
-
-
- -- Open the interfaces browser stack
- ————————————————————————————————————————————————————————————————————————
- on goInterfaces which
-
- global InterfacesInited, InterfacesPath
-
- set cursor to watch
-
- if which is "browser" then
- go cd 1 of stack InterfacesPath in a new window
-
- else if which is "lookup" then
- put the selection into keyWord
- go cd 2 of stack InterfacesPath in a new window
- if the result is not empty then exit goInterfaces
- if keyWord is not empty then
- put keyWord into cd fld "keyWord"
- lookupKeyword
- end if
- end if
-
- end goInterfaces
-
-
-
- -- Open a figure
- ————————————————————————————————————————————————————————————————————————
- on openFigure figRef
-
- global DocumentFolder
-
- if there is a window figRef then
- show window figRef
- exit openFigure
- end if
-
- put DocumentFolder & "Support files:Figures:" & figRef into figPath
-
- if fileExists (figPath) = false then
- answer figRef && "is yet to be supplied."
- exit openFigure
- end if
-
- picture figPath,file,zoom,true
- get the result
- if it contains "not found" then
- answer "Sorry, figure" && figRef && "is yet to be supplied."
- else if it is not empty then answer it
-
- end openFigure
-
-
-
- -- Set a bookmark
- ———————————————————————————————————————————————————————————————————————
- on setBookmark
-
- global Bookmarks
-
- set cursor to watch
-
- -- Limit bookmarks to 60
-
- if number of lines in BookmarkNames ‚â• 60 then
- answer "Sorry, you can't set more than 60 bookmarks."
- exit setBookmark
- end if
-
- -- Get the path of the current stack and the number of current card
-
- put value of word 2 to 99999 of long name of this stack into theStack
- put number of this cd into theCard
-
- -- If there is text selected, use it for the default name
-
- if the selection is empty then
- put empty into theChunk
- put line 1 of bg fld "title" into theName
- else
- put the selectedChunk into theChunk
- put (word 1 to 99999 of (char 1 to 40 of (line 1 of ¬
- the selection))) into theName
- end if
-
- -- If the name's too long, truncate it & tack on an ellipse...
-
- if length(theName) ‚â• 40 then
- repeat with c = 40 down to 1
- if char c of theName = " " then exit repeat
- end repeat
- put char 1 to c - 1 of theName & "..." into theName
- end if
-
- -- Delete commas from the name
-
- repeat
- get offset(",",theName)
- if it = 0 then exit repeat
- delete char it of theName
- end repeat
-
- -- Let user modify the bookmark name
-
- ask "What do you want to call this bookmark?" with theName
- if it is empty then exit setBookmark
- set cursor to watch
- put it into theName
-
- if length(theName) ‚â• 80 then
- repeat with c = 80 down to 1
- if char c of theName = " " then exit repeat
- end repeat
- put char 1 to c - 1 of theName & "..." into theName
- end if
-
- repeat until theName is not in Bookmarks
- ask "You already have a bookmark by this name." with theName
- if it is empty then exit setBookmark else put it into theName
- end repeat
- set cursor to watch
-
- -- Append it to the bookmarks global & menu
-
- put theStack & "," & theCard & "," & theChunk & "," ¬
- & theName & return after Bookmarks
- saveBookmarks
-
- if last menuitem of menu "bookmarks" is "clear all bookmarks..." then ¬
- put "-" after menu "bookmarks"
- put theName after menu "bookmarks" ¬
- with menuMsg "goBookmark" && quote & theName & quote
-
- enable menuItem "Clear a bookmark..." of menu "bookmarks"
- enable menuItem "Clear all bookmarks..." of menu "bookmarks"
-
- end setBookmark
-
-
-
- -- Go to a bookmark
- ———————————————————————————————————————————————————————————————————————-
- on goBookmark bookmarkName
-
- global Bookmarks, BrowserFolder
-
- set cursor to watch
-
- -- Find the entry in the bookmark global
-
- findInXCMD Bookmarks,bookmarkName,1
- get line (item 1 of the result) of Bookmarks
-
- -- Go to the marked card
-
- lock screen
- go cd (item 2 of it) of stack (item 1 of it) in a new window
-
- -- Hilite the marked text
-
- if (item 3 of it) is not empty then
- unlock screen
- select item 3 of it
- end if
-
- end goBookmark
-
-
-
- -- Clear a bookmark
- ———————————————————————————————————————————————————————————————————————-
- on clearOneBookmark
-
- global Bookmarks
-
- -- Put up a dialog box listing the bookmarks, let user delete 'em
-
- put Bookmarks into list
- set cursor to watch
- repeat with n = 1 to number of lines in list
- delete item 1 to 3 of line n of list
- end repeat
-
- get listSelect(1,list,"Clear which bookmark?","Clear", ¬
- "Cancel","20,20,400,200")
- if it is empty then exit clearOneBookmark
-
- -- Find it in the list, delete it; remove it from the menu
-
- findInXCMD Bookmarks,it,1
- put item 1 of the result into b
- if b = zero then exit clearOneBookmark
- delete line b of Bookmarks
- saveBookmarks
-
- delete menuItem it of menu "bookmarks"
-
- -- If there are no more bookmarks, disable the clear/clear all items
-
- if Bookmarks is empty then
- delete menuItem "-" of menu "bookmarks"
- disable menuItem "clear a bookmark..." of menu "bookmarks"
- disable menuItem "clear all bookmarks..." of menu "bookmarks"
- end if
-
- end clearOneBookmark
-
-
-
- -- Clear all bookmarks
- ———————————————————————————————————————————————————————————————————————-
- on clearAllBookmarks
-
- global Bookmarks
-
- answer "Clear all bookmarks?" with "OK" or "Cancel"
- if it is "Cancel" then exit clearAllBookmarks
-
- -- Clear the bookmark list, remove 'em from the menu
-
- set cursor to watch
- put empty into Bookmarks
- saveBookmarks
-
- get (enabled of menuItem "Set a bookmark..." of menu "bookmarks")
-
- put "Set a Bookmark...,Clear a Bookmark...," ¬
- & "Clear All Bookmarks..." after theItems
- put "setBookmark,clearOneBookmark,clearAllBookmarks" after theMsgs
- put theItems into menu "bookmarks" with menuMsgs theMsgs
- set cmdchar of menuItem "set a bookmark..." of menu "bookmarks" to ";"
-
- enableDocMenus it
-
- end clearAllBookmarks
-
-
-
- -- Load bookmarks from bookmarks file (in Preferences folder)
- ———————————————————————————————————————————————————————————————————————
- on loadBookmarks
-
- global Bookmarks, PreferencesFolder
-
- put PreferencesFolder & "Bookmarks" into bookmarksFile
- open file bookmarksFile
- read from file bookmarksFile until "" -- end of file
- close file bookmarksFile
- put it into Bookmarks
-
- end loadBookmarks
-
-
-
- -- Load document list from document list file (in Preferences folder)
- ———————————————————————————————————————————————————————————————————————
- on loadDocumentList
-
- global DocumentList, PreferencesFolder
-
- put PreferencesFolder & "Document List" into docListFile
- open file docListFile
- read from file docListFile until "" -- end of file
- close file docListFile
- put it into DocumentList
-
- -- Delete the docRefNums from the list; they're invalid
-
- repeat with d = 1 to number of lines in DocumentList
- put empty into item 3 of line d of DocumentList
- end repeat
-
- end loadDocumentList
-
-
-
- -- Save document list (in Preferences folder)
- ———————————————————————————————————————————————————————————————————————
- on saveDocumentList
-
- global DocumentList, PreferencesFolder
-
- put PreferencesFolder & "Document List" into docListFile
- open file docListFile
- write DocumentList to file docListFile
- close file docListFile
-
- end saveDocumentList
-
-
-
- -- Save bookmarks to bookmarks file (in Preferences folder)
- ———————————————————————————————————————————————————————————————————————
- on saveBookmarks
-
- global Bookmarks, PreferencesFolder
-
- put PreferencesFolder & "Bookmarks" into bookmarksFile
- open file bookmarksFile
- write Bookmarks to file bookmarksFile
- close file bookmarksFile
-
- end saveBookmarks
-
-
-
- -- Open a note
- ———————————————————————————————————————————————————————————————————————
- on openNotes
-
- global PreferencesFolder, NotesDirectory, NoteFilePath, ¬
- NoteWindowRect, NoteText
-
- set cursor to watch
-
- if there is a window "Note" then
- send "select" to window "Note"
- exit openNotes
- end if
-
- -- Build the note file name using the stack name and card #
-
- put "Note" && number of this cd && "(" ¬
- & char 1 to 18 of short name of this stack & ")" into noteFile
- put PreferencesFolder & noteFile into NoteFilePath
-
- lock screen
- put empty into NoteText
-
- -- If it card # in NotesDirectory, get the content of the note file
-
- if noteFile is in NotesDirectory then
- open file NoteFilePath
- read from file NoteFilePath until "" -- end of file
- close file NoteFilePath
- put it into NoteText
- end if
-
- -- Open the window. TEXWindow params are: window name, text,
- -- rect (items), font, size, lineHeight, wrap width in pixels
-
- TEXWindow "Note", NoteText ,¬
- item 1 of NoteWindowRect, item 2 of NoteWindowRect, ¬
- item 3 of NoteWindowRect, item 4 of NoteWindowRect, ¬
- "geneva", "10","14",item 3 of NoteWindowRect ¬
- - item 1 of NoteWindowRect - 20
-
- end openNotes
-
-
-
- -- The text window's been closed
- ________________________________________________________________________
- on TEXWindowClosing windowName, isDirty
-
- global NoteWindowRect, NoteText
-
- -- Get the current text and record the window rect
-
- put text of window "Note" into newNoteText
- put the globalRect of window "Note" into NoteWindowRect
- setPreferences
-
- -- Did the user change the text in the note window?
-
- if newNoteText = NoteText then return true -- close the window
-
- if newNoteText is empty then
- answer "Delete this note?" with "Cancel" or "Delete"
- if it is "Cancel"then
- return true
- end if
- else
- answer "Save changes to note?" with "Cancel" or "Discard" or "Save"
- if it is "discard" then return true -- close the window
- else if it is "cancel" then return false -- leave the window open
- end if
-
- -- The user hit the "Save" button
-
- updateNotes newNoteText
- return true -- close the window
-
- end TEXWindowClosing
-
-
-
- -- Update the note file for this card, and the notes directory
- ________________________________________________________________________
- on updateNotes newNoteText
-
- global PreferencesFolder, NotesDirectory, NoteText, NoteFilePath
-
- -- If the notes are empty, delete the note file and hide the note
- -- button; otherwise, save the notes and show the note button
-
- if newNoteText = empty then
- deleteFile NoteFilePath
- hide bg btn "showNotes"
- else
- open file NoteFilePath
- write newNoteText to file NoteFilePath
- close file NoteFilePath
- show bg btn "showNotes"
- end if
-
- -- Update the notes directory
-
- put newNoteText into NoteText
- put folderContents(PreferencesFolder,"Files") ¬
- & return into NotesDirectory
-
- end updateNotes
-
-
-
- -- Print selection, section or chapter
- ———————————————————————————————————————————————————————————————————————
- on printText which
-
- if which is "theselection" then
- if the selection is empty then
- answer "There is no text selected."
- else
- set printTextFont to monaco
- set printTextSize to 9
- set printTextHeight to 12
- print the selection
- end if
-
- else if which is "section" then
- open report printing with template "full page"
- print this cd
- close printing
-
- else if which is "chapter" then
- set cursor to watch
- lock screen
- push cd
- repeat until bg fld "chapterDisplay" ≠ bg fld "chapterDisplay" ¬
- of prev cd
- go prev cd
- end repeat
- open report printing with template "full page"
- repeat
- print this cd
- if bg fld "chapterDisplay" ≠ bg fld "chapterDisplay" of ¬
- next cd then exit repeat
- go next cd
- end repeat
- close printing
- pop cd
- end if
-
- end printText
-
-
-
- -- Update the checkmarks on the document menu
- ———————————————————————————————————————————————————————————————————————
- on updateDocMenuMarks which
-
- global DocumentList, CurrentDocNum
-
- repeat with d = 1 to number of lines in DocumentList
- if which is not empty then
- set the checkMark of menuItem d + 2 of menu "documents" to which
- else set the checkMark of menuItem d + 2 of menu "documents" to (d = CurrentDocNum)
- end repeat
-
- end updateDocMenuMarks
-
-
-
- -- Open the browser TOC files for a given document folder
- ———————————————————————————————————————————————————————————————————————-
- function openBrowserFiles docFolder
-
- put docFolder & "Support files:Browser.i" into tocIndex
- put docFolder & "Support files:Browser.d" into tocData
-
- get IndeXFCN(iOpen,tocIndex,true,false,tocData)
- if word 1 of it = 0 then return word 2 of it
- else
- answer "Couldn't open the table of contents files." ¬
- && "The files “browser.i” and “browser.d” must be in the" ¬
- && "document's “Support files” folder."
- return empty
- end if
-
- end openBrowserFiles
-
-
-
- -- Find and init the search stack
- ———————————————————————————————————————————————————————————————————————-
- on findSearch
-
- global BrowserFolder
-
- get BrowserFolder & "Support files:Search"
- if there is a file it then
- start using stack it
- initSearch it -- in the search stack
- end if
-
- end findSearch
-
-
-
- -- Find and initialize the interfaces browser stack
- ———————————————————————————————————————————————————————————————————————-
- on findInterfaces
-
- global BrowserFolder
-
- get BrowserFolder & "Support files:Interfaces:Interfaces Browser"
- if there is a file it then
- start using stack it
- initInterfaces it -- in the interfaces stack
- end if
-
- end findInterfaces
-
-
-
- -- Commas, parens & hypens in file names will screw various things up
- ———————————————————————————————————————————————————————————————————————-
- function validDocPath docPath
-
- if (docPath contains ",") or (docPath contains "(") or ¬
- (docPath contains "-") then
- answer "Document names cannot contain commas, parentheses" ¬
- && "or dashes."
- return false
- else return true
-
- end validDocPath</script>
- <background id="2796" file="background_2796.xml" name="" />
- <card id="2935" file="card_2935.xml" marked="false" name="" owner="2796" />
- <card id="4060" file="card_4060.xml" marked="false" name="standardDocument" owner="2796" />
- </stack>
-